home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / comm / bbs / cit_src_AD08.lha / liblog2.c < prev    next >
C/C++ Source or Header  |  1997-07-27  |  2KB  |  76 lines

  1. /*
  2. *                               liblog2.c
  3. *
  4. * Citadel log code for the library
  5. */
  6. /*
  7. *                               history
  8. *
  9. * 89Feb05 HAW  File created.
  10. */
  11. #include "ctdl.h"
  12. /*
  13. *                               Contents
  14. *
  15. * findPerson()          Loads a log record.
  16. * PersonExists()                See if given name is valid for mail.
  17. */
  18. extern CONFIG cfg;
  19. extern logBuffer logTmp, logBuf;
  20. extern LogTable  *logTab;
  21. extern char onConsole, remoteSysop;
  22.  
  23. /*
  24. * findPerson()
  25. *
  26. * This function loads a log record for named person.
  27. * RETURNS: ERROR if not found, else log record #
  28. */
  29. int findPerson(char *name, logBuffer *lBuf)
  30.   {
  31.   int  h, i, foundIt, logNo = ERROR;
  32.   if (strLen(name) == 0) return ERROR;
  33.   if (strCmpU(name, "Citadel") != SAMESTRING)
  34.     {
  35.     h   = hash(name);
  36.     for (foundIt = i = 0;  i < cfg.MAXLOGTAB && !foundIt;  i++)
  37.       {
  38.       if (logTab[i].ltnmhash == h)
  39.         {
  40.         getLog(lBuf, logNo = logTab[i].ltlogSlot);
  41.         if (lBuf->lbflags.L_INUSE &&
  42.         strCmpU(name, lBuf->lbname) == SAMESTRING)
  43.           {
  44.           foundIt = TRUE;
  45.  
  46.           }
  47.  
  48.         }
  49.  
  50.       }
  51.  
  52.     }
  53.   else foundIt = FALSE;
  54.   if (!foundIt)    return ERROR;
  55.   else             return logNo;
  56.  
  57.   }
  58. /*
  59. * PersonExists()
  60. *
  61. * This function will check to see if the given name is valid for mail.
  62. *
  63. * This includes special processing for "Sysop" and "Citadel".
  64. */
  65. int PersonExists(char *name)
  66.   {
  67.   int result;
  68.   if ((strCmpU("Citadel", name) == SAMESTRING && HalfSysop()) ||
  69.   strCmpU("sysop", name) == SAMESTRING)
  70.   return (int)cfg.MAXLOGTAB;       /* signals special string */
  71.   result = findPerson(name, &logTmp);
  72.   if (result != ERROR) strCpy(name, logTmp.lbname);
  73.   return result;
  74.  
  75.   }
  76.